<%-- 
  - Author: Neha Chauhan
  - Date: 11-Apr-2011
  - Copyright Notice: TRAKHEES
  - Description: form.jsp
 --%>

<%@ include file="/WEB-INF/view/include.jsp"%>
<%@ page import="ae.pcfc.etks.online.web.*"%>
<script type="text/javascript">
	$().ready(function() {
		
		
		$('input[name=clientType]').click(function() {
	        var clientType= $("input[name=clientType]:checked").val();
	        if(clientType=='C'){
	            $(".person").hide();
	            $(".company").show();
	        }else{
	            $(".company").hide();
	            $(".person").show();
	        }
	    });
		$("#RecallPin").validate({
			onfocusout:false,
			onkeyup:false,
			onclick: false,				
			rules : {
				clientType: "required",
				strLicenseIssuingAuth : {
				    required: function(element) {
				        return $("input[name=clientType]:checked").val() == 'C';
				      }
				},

				strLicenseNumber : {
				    required: function(element) {
				        return $("input[name=clientType]:checked").val() == 'C';
				      }
				},
				strEmail	:	{
				    required: function(element) {
					        return $("input[name=clientType]:checked").val() == 'P';
					},
				   email: true
				}
			},
			showErrors : function(errorMap, errorList) {

				var errors = '<ul>';
				var label;
				if (errorList.length) {
					$.each(errorMap, function(name, value) {
						label = $("label[for='" + name + "']").html();
						label = value + '[' + label + ']';
						errors = errors + '<li>' + label + '</li>';

					});
					errors = errors + '</ul>';
					jAlert('error', errors, '<spring:message code="label.errormessage" />');
				}
			}
		});

	});
</script>


<div id="container" dir='<spring:message code="page.dir"/>'
	align='<spring:message code="page.align"/>'>
	<form:form name="RecallPin" id="RecallPin" method="POST" 
		modelAttribute="<%=ConstantsAdmin.CLIENT_REGISTER_RECALLPIN_MODEL_KEY %>">
		
		
		<spring:hasBindErrors
			name="<%=ConstantsAdmin.CLIENT_REGISTER_RECALLPIN_MODEL_KEY %>">
			<script type="text/javascript">
				$(document)
						.ready(
								function() {
									jAlert(
											'error',
											'<li><form:errors path="*" delimiter="<li>"/>',
											'<spring:message code="label.errormessage" />');
								});
			</script>
		</spring:hasBindErrors>
		
		<div class="ui-widget_c ui-corner-all t_fin-black-txt">
			<div class="ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix"><spring:message code="client.register.recall.pin.form" /></div>
			 	<div class="fm-req">
				     <br/><spring:message code="client.register.recall.pin.message" /><br/>
			    </div>
			
	       	<div class="t_form-left">
	       		<div class="fm-req"><form:label path="clientType">
					<span class="t_star">*</span>
						<spring:message code="label.client.type" />
					</form:label>
					<div class="fm-multi">
					<c:forEach items="${clientTypesModelKey}" var="label">
						<c:out value="${label.displayLabel}"></c:out>
						<form:radiobutton path="clientType"	value="${label.id}" id="clientType" cssClass="opt-input"/>
					</c:forEach>
					</div>
				</div>
				<div class="fm-req company">
					<form:label path="strLicenseIssuingAuth">
					<span class="t_star">*</span>
						<spring:message code="label.company.lia" />
					</form:label>
					<c:choose>
						<c:when
							test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
							<form:select path="strLicenseIssuingAuth"
								items="${nonClientCompanyRegistrationClientLicIssueAuthList}"
								id="strLicenseIssuingAuth" itemLabel="labelAr" itemValue="id"
								class="fm-opt" />
						</c:when>
						<c:otherwise>
							<form:select path="strLicenseIssuingAuth"
								items="${nonClientCompanyRegistrationClientLicIssueAuthList}"
								id="strLicenseIssuingAuth" itemLabel="labelEn" itemValue="id"
								class="fm-opt" />
						</c:otherwise>
					</c:choose>
				</div>
				<div class="fm-req company">
					<form:label path="strLicenseNumber">
					<span class="t_star">*</span>
						<spring:message code="label.company.lno" />
					</form:label>
					<form:input path="strLicenseNumber" id="strLicenseNumber"
						name="LicNum" size="20" maxlength="100" />
				</div>
			    <div class="fm-req person"> 
		           <form:label path="strEmail">
		           <span class="t_star">*</span>
		                  <spring:message code="client.register.email" />
		           </form:label>
		           <form:input path="strEmail" id="strEmail" size="30" maxlength="100" />
		              
				 </div>
			<c:choose>
				<c:when test="${clientRecallpinRegister.clientType == 'P'}">
					<script>
					$(".person").show();
					$(".company").hide();
					</script>
				</c:when>
				<c:when test="${clientRecallpinRegister.clientType == 'C'}">
					<script>
					$(".person").hide();
					$(".company").show();
					</script>
				</c:when>
				<c:otherwise>
					<script>
					$(".person").hide();
					$(".company").hide();
					</script>
				</c:otherwise>
			</c:choose>
				 
			</div>			 
			 	<br/>
			 	<div id="fm-submit" class="fm-req">
					<input type="submit" name="continue" value="<spring:message code="label.button.continue" />" class="t_btns submit"/>
					<input type="reset" name="reset" value="<spring:message code="label.button.reset" />" class="t_btns reset"/>
	
		     	</div>	

		</div>	
	</form:form>
</div>	